function TimeTable(name){
  this.name = name;
  this.toParis = [];
  this.toLondon = [];
  this.toBerlin = [];
  
  this.showTimeTable = function(){
    console.log(this.toParis.length);
    console.log(this.toLondon.length);
    console.log(this.toBerlin.length);
  }
  
  this.checkNew = function(time, beingFlights){
    flights = new Object();
    flights.toParis = [];
    flights.toLondon = [];
    flights.toBerlin = [];
    var flag = true;
    
    if(this.toParis.length != 0){
      for(var i = 0; i < this.toParis.length; i++){
        if(this.toParis[i] == time){
          for(j = 0; j < beingFlights[0].length; j++){
            if(beingFlights[0][j] == time){
              flag = false;
            }
          }
          if(flag) flights.toParis.push(time);
        }
      }
    }
    if(this.toLondon.length != 0){
      for(var i = 0; i < this.toLondon.length; i++){
        if(this.toLondon[i] == time){
          for(j = 0; j < beingFlights[1].length; j++){
            if(beingFlights[1][j] == time){
              flag = false;
            }
          }
          if(flag) flights.toLondon.push(time);
        }
      }
    }
    if(this.toBerlin.length != 0){
      for(var i = 0; i < this.toBerlin.length; i++){
        if(this.toBerlin[i] == time){
          for(j = 0; j < beingFlights[2].length; j++){
            if(beingFlights[2][j] == time){
              flag = false;
            }
          }
          if(flag) flights.toBerlin.push(time);
        }
      }
    }
    return flights;
  }
  
  this.addFlight = function(to, time){
    switch(to){
      case "toParis" : {
        this.toParis.push(time);
        break;
      }
      case "toLondon" : {
        this.toLondon.push(time);
        break;
      }
      case "toBerlin" : {
        this.toBerlin.push(time);
        break;
      }
      default : {
        alert("Nie można dodać " + to);
      }
    }
  }
  
  this.returnTimeTable = function(){
    return Array(this.toParis, this.toLondon, this.toBerlin);
  }
}
